import tinymce from 'tinymce'
import { sleep, emit } from '@/utils/helpers'

export default function (editor) {
  editor.on('addDocContent', async (args) => {
    const node = editor.selection?.getNode?.()
    editor.dom.insertAfter(args.blocks, node)
    tinymce.activeEditor.undoManager.add()
    emit('close-docContent-insert-dialog')
    await sleep()
    editor.fire('contentPasted')
  })
}
